package com.yklx.youke.entity;

import jakarta.persistence.*;
import java.time.LocalDateTime;

@Entity
@Table(name = "user_roles")
@IdClass(UserRoleKey.class)  // 使用复合主键
public class UserRole {

    @Id
    @Column(name = "user_id", length = 36)
    private String userId;

    @Id
    @Column(name = "role_id", length = 32)
    private String roleId;

    @Column(name = "assigned_at")
    private LocalDateTime assignedAt;

    // 构造函数
    public UserRole() {}

    public UserRole(String userId, String roleId) {
        this.userId = userId;
        this.roleId = roleId;
        this.assignedAt = LocalDateTime.now();
    }

    // Getter 和 Setter 方法
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public LocalDateTime getAssignedAt() {
        return assignedAt;
    }

    public void setAssignedAt(LocalDateTime assignedAt) {
        this.assignedAt = assignedAt;
    }
}